<?php
	// CALL ALL DOCUMENTS & DOWNLOADS BASED ON PAGE / POST / PRODUCT ID
	// Include on pages, posts, products, etc
?>

<?php // GENERAL DOCUMENTS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'General Document',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related General Documents</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';

	}
	wp_reset_query();
?>

<?php // BROCHURES
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Brochure',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Brochures</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // DATA SHEETS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Data Sheet',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Data Sheets</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // INSTALLATION MANUALS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Installation Manual',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Installation Manuals</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // WARRANTIES
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Warranty',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Warranties</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // SRCC OG-100 CERTIFICATIONS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'SRCC OG-100 Certification',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related SRCC OG-100 Certifications</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // SRCC OG-300 CERTIFICATION
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'SRCC OG-300 Certification',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related SRCC OG-300 Certifications</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // TECHNICAL DRAWINGS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'CAD File',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related CAD Files &amp; Technical Drawings</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // PIPING DIAGRAMS
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Piping Diagram',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Piping Diagrams</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>

<?php // CASE STUDIES
	
	$args = array(
		'post_type' => 'document',
		'tax_query' => array(
			array(
				'taxonomy' => 'wpdr-file-tags',
				'field' => 'slug',
				'terms' => ''.get_the_ID().''
			)
		)
		'meta_query' => array(
            array(
                'key' => 'documenttype',
                'value' => 'Case Study',
                'compare' => '=='
            )
 		)
	);

	$docs_general = new wp_query(array($args);

	if($docs_general->have_posts()) {
		echo '<h3>Related Case Studies</h3>';
		echo '<ul>';
		
		while($docs_general->have_posts()) : $docs_general->the_post();

			echo '<li><a href="'.get_the_permalink().'" target="_blank">'.the_title().'</a></li>';

		endwhile;

		echo '</ul>';
		
	}
	wp_reset_query();
?>